Repository navigation
fix: don't flag a search-truncated dir as having hidden matches (#1214) - #1228
Open
shivampwm2020 wants to merge 1 commit into
Open
shivampwm2020 wants to merge 1 commit into
shivampwm2020 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1214
Problem (actual error/observed behavior)
During a search, a directory is marked as truncated — which is what draws the
…ellipsis (src/display/displayable_tree.rs:365,TreeLineType::Dir if line.unlisted > 0) — even when the directory still has visible matching children under it, i.e. when nothing relevant is hidden.Related to #1213 (different point, not addressed here).
Root cause
TreeBuilder::make_tree_line(src/tree_build/builder.rs) computed the number of hidden children as:childrenholds all children of the directory, including ones that don't match the active search (non-matching directories are kept because they may contain matching descendants; non-matching files are also part of the sorted child list at this stage).next_child_idxonly advances for children actually visited during the walk. So every not-yet-visited non-matching child was counted as an "unlisted" (hidden) child, and the ellipsis claimed hidden matches that simply don't exist.This is not a stale-value problem: the predicate is computed against the unfiltered child set instead of the children that survive the active search filter. Confirmed by instrumenting the builder: directories with zero matching children could report
unlisted = 9.Fix
Count only the children that can actually end up displayed, i.e. children matching the active search:
Non-matching children can never become a displayed line, so they must not trigger the ellipsis. Minimal, one concern, no behavior change when no search is active (all children then have
has_match == true).Testing
Regression test added in
src/tree_build/builder.rs(tree_build::builder::tests::unlisted_counts_only_matching_children_during_search). It builds a wide/deep temp tree where each directory holds a few matching files plus many non-matching siblings, runs a search with a small budget so the walk stops early, and asserts that no directory is flagged truncated while no matching child is left hidden.Exact commands and results:
0in every failing case.)cargo clippy --lib --testsreports only pre-existingused assert_eq! with a literal boolwarnings in existing tests; none introduced by this change.What I did not run: the full TUI / end-to-end check (driving a real
brootsession), and the full workspace test suite. The reproduction is at the tree-building logic level.